<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    function getData() {
        return new Promise(resolve => {
            setTimeout(() => {
                resolve({
                    code: 0,
                    data: 66
                })
            }, 1000)
        })
    }

    function testHandle(flag) {
        if (flag) {
            return getData()
        }
        return {
            code: 1,
            data: null
        }
    }

    async function testHandle2(val) {
        const result = await testHandle(val)
        console.log(result);
    }

    testHandle2(false)
</script>


</body>
</html>
